
package com.work.mvc.controler;

import com.vaadin.ui.*;
import com.vaadin.ui.Button.ClickEvent;
import com.work.mvc.*;
import com.work.mvc.view.window.WorkTimeWindowView;

public class WorkTimeWindowController implements Controller, Button.ClickListener {

	private static final long serialVersionUID = -7183583377863125291L;

	private WorkTimeWindowView view;
	
	private MonthWorkTimeTableController monthTableController;

	public WorkTimeWindowController(WorkTimeWindowView workTimeWindowView) {
		this.view = workTimeWindowView;
	}

	@Override
	public void buttonClick(ClickEvent event)
	{
		if (event.getButton() == view.getSaveButton()) {
			view.getForm().commitForm();
		} else if (event.getButton() == view.getCloseButton()) {
			Window window = (Window) view;
			window.getUI().removeWindow(window);
			monthTableController.reladTable(view.getFormBean());
		}
	}
	
	@Override
	public View getView()
	{
		return view;
	}

	public void setParentComponentController(MonthWorkTimeTableController monthWorkTimeTableController)
	{
		this.monthTableController = monthWorkTimeTableController;
	}
}
